const app = getApp()
import {
    _post,
} from '../../../../utils/httpUtils.js'
Page({
    data: {
        navbarData: {
            showCapsule: 1, //是否显示左上角图标
            title: '历史记录' //导航栏 中间的标题
        },
        height: app.globalData.height * 2 + 20,
        list: [{
                "article_a_id": "182",
                "article_a_desc": "卤肉开胃，促进生长发育，改善缺铁性贫血",
                "article_comment_count": "2",
                "article_a_create_date": "2019-03-16",
                "article_zan_count": "419",
                "article_a_browse": "1851",
                "article_a_title": "西义兴卤肉",
                "article_a_main_pic": "https://qn.zhijianjiaxiang.com/image/2019-03-16/20190316151456348176027.png",
                "article_a_user_go_site": "1063",
                "article_collect_count": "1557",
                "article_sales_volume": "0",
                "article_a_scenic_area": ""
            },
            {
                "article_a_id": "178",
                "article_a_desc": "郑州黄河鲤鱼含蛋白质 高达90%以上，且鱼肉松软，易于消化吸收和利用。",
                "article_comment_count": "0",
                "article_a_create_date": "2019-03-16",
                "article_zan_count": "351",
                "article_a_browse": "1818",
                "article_a_title": "鲤鱼三吃",
                "article_a_main_pic": "https://qn.zhijianjiaxiang.com/image/2019-03-16/20190316113235378419913.png",
                "article_a_user_go_site": "1778",
                "article_collect_count": "1710",
                "article_sales_volume": "0",
                "article_a_scenic_area": ""
            },
            {
                "article_a_id": "176",
                "article_a_desc": "一碗热腾腾的烩羊肉端上桌，白白的羊肉汤上面的羊肉散发着迷人的香气，让人垂涎欲滴。吃进嘴里也是满口留香，回味无穷。",
                "article_comment_count": "0",
                "article_a_create_date": "2019-03-16",
                "article_zan_count": "546",
                "article_a_browse": "1091",
                "article_a_title": "烩羊肉",
                "article_a_main_pic": "https://qn.zhijianjiaxiang.com/image/2019-03-16/20190316144032910093767.png",
                "article_a_user_go_site": "1196",
                "article_collect_count": "1118",
                "article_sales_volume": "0",
                "article_a_scenic_area": ""
            },
            {
                "article_a_id": "172",
                "article_a_desc": "巩义",
                "article_comment_count": "2",
                "article_a_create_date": "2019-03-16",
                "article_zan_count": "325",
                "article_a_browse": "1672",
                "article_a_title": "巩义老君烧鸡",
                "article_a_main_pic": "https://qn.zhijianjiaxiang.com/image/2019-03-16/20190316144211704578556.png",
                "article_a_user_go_site": "915",
                "article_collect_count": "1119",
                "article_sales_volume": "0",
                "article_a_scenic_area": ""
            }
        ]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function() {
        // this.getList(1)
    },

    getList(pageNum) {
        let _data = {
            ac_mark: this.data.queryData.ac_mark,
            city_name: this.data.queryData.city_name,
            page: pageNum
        }
        // console.log(_data)
        _post('/api/Article/getCateArticleList', _data, res => {
            // console.log(res.data)
            if (res.data.code == 1) {
                if (pageNum == 1) { //下拉重置数据
                    if (res.data.data.list == false) {
                        wx.showToast({
                            title: '没有更多数据了',
                            icon: 'none',
                            duration: 2000
                        })
                    }
                    this.setData({
                        list: res.data.data.list,
                        pageNum: pageNum
                    })
                } else if (JSON.stringify(res.data.data.list) != '[]') { //有数据添加,没数据弹出提示
                    this.setData({
                        list: this.data.list.concat(res.data.data.list),
                        pageNum: pageNum
                    })
                } else {
                    wx.showToast({
                        title: '没有更多数据了',
                        icon: 'none',
                        duration: 2000
                    })
                }
            } else {
                wx.showToast({
                    title: res.data.msg,
                    icon: 'none',
                    duration: 2000
                })
            }
        })
    },

    detail(e) { //进入详情
        let id = e.currentTarget.dataset.id;
        wx.navigateTo({
            url: `/pages/public/article_detail/article_detail?id=${id}`,
        })
    },
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {
        this.getList(1)
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {
        this.getList(this.data.pageNum + 1)
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})